-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Frontend Infrastructure for Role & Authentication #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tion Co-authored-by: vinod0m <221896197+vinod0m@users.noreply.github.com>
| next_page = url_for('main.dashboard') | ||
|
|
||
| flash('Logged in successfully!', 'success') | ||
| return redirect(next_page) |
Check warning
Code scanning / CodeQL
URL redirection from remote source Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the open redirect vulnerability, we need to ensure that the next_page parameter cannot be used to redirect users to an external site. The best way to do this is to use Python's urllib.parse.urlparse to parse the next_page value, and only allow the redirect if both the netloc and scheme are empty (i.e., it's a relative path). Additionally, we should remove any backslashes from the input, as browsers may interpret them as forward slashes. The fix should be applied in the login function, specifically where next_page is validated before being passed to redirect. We will need to import urlparse from urllib.parse at the top of the file.
-
Copy modified line R7 -
Copy modified lines R85-R91
| @@ -4,6 +4,7 @@ | ||
| import os | ||
| from datetime import datetime | ||
| from flask import Flask, Blueprint, render_template, request, flash, redirect, url_for, jsonify, current_app | ||
| from urllib.parse import urlparse | ||
| from flask_login import LoginManager, login_user, logout_user, current_user | ||
| from flask_migrate import Migrate | ||
| from flask_wtf.csrf import CSRFProtect, validate_csrf | ||
| @@ -81,7 +82,13 @@ | ||
| db.session.commit() | ||
|
|
||
| next_page = request.args.get('next') | ||
| if not next_page or not next_page.startswith('/'): | ||
| # Sanitize and validate next_page to prevent open redirect | ||
| if next_page: | ||
| next_page = next_page.replace('\\', '') | ||
| parsed = urlparse(next_page) | ||
| if parsed.netloc or parsed.scheme: | ||
| next_page = url_for('main.dashboard') | ||
| else: | ||
| next_page = url_for('main.dashboard') | ||
|
|
||
| flash('Logged in successfully!', 'success') |
…d integration guide Co-authored-by: vinod0m <221896197+vinod0m@users.noreply.github.com>
This PR implements a comprehensive frontend infrastructure with role-based authentication for the SDLC Core system. The implementation provides a complete web-based user management system with secure authentication, granular access control, and a modern responsive interface.
Key Features Implemented
🔐 Authentication System
👥 Role-Based Access Control (RBAC)
@require_role(),@admin_required,@login_requireddecorators🌐 Modern Web Interface
🔌 REST API Endpoints
Complete API implementation for programmatic access:
POST /auth/api/login- User authentication with JSON responseGET /auth/api/user/profile- User profile informationGET /api/admin/users- User management (admin only)GET /api/admin/roles- Role management (admin only)All endpoints include proper HTTP status codes, error handling, and JSON responses.
Technical Implementation
Architecture
The implementation follows Flask's application factory pattern with modular components:
Database Models
Security Features
Screenshots
Home Page
Login Interface
User Dashboard
Admin Panel
Quick Start
Integration Ready
The frontend infrastructure is designed for seamless integration with existing SDLC Core components. It provides authentication decorators that can be used throughout the system to protect LLM endpoints, agent deployments, analytics functions, and other sensitive operations based on user roles.
The system includes comprehensive documentation (
src/frontend/README.mdandFRONTEND_INTEGRATION.md) with examples for integrating authentication into existing components.Fixes SoftwareDevLabs/frontend#4.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.